package com.ojoin.trade.common.web.shiro;

import java.io.Serializable;

import com.ojoin.trade.common.utils.CommonUtils;
import com.ojoin.trade.common.web.domain.User;

/**
 * 授权用户信息
 */
public class Principal implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private String id; // 编号
	private String loginName; // 登录名
	private String name; // 姓名
	private String loginType;//登录系统
	

	public String getLoginType() {
		return loginType;
	}

	public void setLoginType(String loginType) {
		this.loginType = loginType;
	}

	public Principal(User user) {
		this.id = String.valueOf(user.getId());
		this.loginName = user.getLoginName();
		this.name = user.getName();
		this.loginType=user.getLoginType();
	}

	public String getId() {
		return id;
	}

	public String getLoginName() {
		return loginName;
	}

	public String getName() {
		return name;
	}

	/**
	 * 获取SESSIONID
	 */
	public String getSessionid() {
		try{
			return (String) CommonUtils.getShiroSession().getId();
		}catch (Exception e) {
			return "";
		}
	}
	
	@Override
	public String toString() {
		return id;
	}

}